<!DOCTYPE html>
<html>
<head>
<title>Canvas 2D global alpha test</title>
<style type="text/css">
body {
    color: #fff;
}
canvas {
    border-width: 1px;
    border-style: solid;
    border-color: #fff;
}
</style>
<script>
    document.addEventListener("DOMContentLoaded", function() {
        ctx = document.getElementById("foo").getContext("2d");

        image = new Image(100, 100);
        image.onload = drawImage;
        image.src = "car.png";

        function drawImage() {

            ctx.drawImage(image, 0, 0, 400, 400);

        }

        var width = 200;
        var height = 100;

        ctx.globalAlpha = 0.4;
        ctx.font = "100px serif";
        ctx.fillText("hello friends", 50, 90);


        for (var i = 0; i < 2; i++)
        {
            ctx.globalAlpha = 0.5;
            ctx.fillStyle = 'red';
            ctx.fillRect(10, 10, width, height);

            ctx.globalAlpha = 0.6;
            ctx.strokeStyle = 'blue';
            ctx.strokeRect(10, 10, width, height);

            ctx.scale(0.5, 0.5);
            ctx.translate(10 + width * 2, 10 + height * 2);
        }

    });
</script>
</head>
<body>
    <canvas id="foo" width="1000" height="1000"></canvas>
</body>
</html>
